//
//  JznWebView.m
//  taishan
//
//  Created by mac on 2019/4/8.
//  Copyright © 2019年 jznrj. All rights reserved.
//

#import "JznWebView.h"
#import <WebKit/WKWebViewConfiguration.h>
@implementation JznWebView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(id) init{
    self = [super init];
    if (!self) {
        return nil;
    }
    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
    configuration.userContentController = [WKUserContentController new];
    configuration.allowsInlineMediaPlayback = YES;
    
    WKPreferences *preferences = [WKPreferences new];
    preferences.javaScriptCanOpenWindowsAutomatically = YES;
    configuration.preferences = preferences;
   
    self.scrollView.bounces = NO;
    self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.showsHorizontalScrollIndicator = NO;
    return self;
}

-(void) loadLocalFile:(NSString* )fileName
                 type:(NSString *)fileType{
    
    NSString *urlStr1 = [[NSBundle mainBundle] pathForResource:fileName ofType:fileType];
    NSURL *fileURL = [NSURL fileURLWithPath:urlStr1];
    [self loadFileURL:fileURL allowingReadAccessToURL:fileURL];
    
}
-(void) loadServerUrl:(NSString*) serverUrl{
    
    NSString *urlString= serverUrl;
    NSURL *url=[ NSURL URLWithString :urlString];
    NSURLRequest *request=[ NSURLRequest requestWithURL :url];
    [self loadRequest :request];
}
@end
